/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.td.engine;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 *
 * @author Администратор
 */
public class Path {
    
    private List<Node> nodeList;
    
    public Path() {
        nodeList = new ArrayList<Node>();
        Random r = new Random();
        for (int i = 0; i < 20; i++){
            nodeList.add(new Node(r.nextInt(31), r.nextInt(31)));
        }
    }


    ShapeRenderer shapeRenderer;

    public void debugRender(float scaleX, float scaleY) {
        if (shapeRenderer == null) {
            shapeRenderer = new ShapeRenderer();
        }
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
        shapeRenderer.setColor(Color.RED);
        for (int i = 0; i < nodeList.size() - 1; i++) {
            Node n1 = nodeList.get(i);
            Node n2 = nodeList.get(i+1);
            shapeRenderer.line(n1.x * scaleX + scaleX * 0.5f, n1.y * scaleY + scaleY * 0.5f, n2.x * scaleX + scaleX * 0.5f, n2.y * scaleY + scaleY * 0.5f);
        }

        shapeRenderer.end();
    }
    
    public Node getNext(int i) {
        return nodeList.get(i+1);
    }
    
    public Node getStart() {
        return nodeList.get(0);
    }
    
    public Node getEnd() {
        return nodeList.get(nodeList.size());
    }
    
    public int getNodeCount() {
        return nodeList.size();
    }
    
    public static class Node {
        public final int x;
        public final int y;
        
        public Node(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}
